package com.xu.crawler.util;

/**
 * Created by clear on 2018/7/10.
 */
public class RequestParamBuilder {

    private StringBuilder config;

    public RequestParamBuilder(String target) {
        this.config = new StringBuilder(target);
        this.config.append('?');
    }

    public RequestParamBuilder addParameter(String key, String val) {
        this.config.append(key).append("=").append(val).append("&");
        return this;
    }

    public RequestParamBuilder addParameter(String key, int val) {
        this.config.append(key).append("=").append(val).append("&");
        return this;
    }

    public RequestParamBuilder addParameter(String key, long val) {
        this.config.append(key).append("=").append(val).append("&");
        return this;
    }

    public String build() {
        return this.config.substring(0, config.length() - 1);
    }
}
